package tests.flexunit.utils
{
	import flexunit.framework.AssertionFailedError;
	import flexunit.framework.TestCase;
	
	import funit.resources.AssertResources;
	
	import mx.core.Application;
	
	import sv.utils.ClassUtil;
	
	public class GetSimpleBaseClassNameTests extends TestCase
	{
		
		
		public function GetSimpleBaseClassNameTests( methodName:String = null )
		{
			super(methodName);
		}
		
		
//------------------------------------------------------------------------------
		
		public function testGetNameByInstance() : void
		{
			assertEquals( "LayoutContainer", ClassUtil.getSimpleBaseClassName(new Application()) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetNameByClass() : void
		{
			assertEquals( "LayoutContainer", ClassUtil.getSimpleBaseClassName(Application));
		}

//------------------------------------------------------------------------------
		
		public function testGetNameByBaseInstance() : void
		{
			assertNull( ClassUtil.getSimpleBaseClassName(new Object()) );
		}

//------------------------------------------------------------------------------
		
		public function testGetNameByBaseClass() : void
		{
			assertNull( ClassUtil.getSimpleBaseClassName(Object) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetNameByPrimitiveInstance() : void
		{
			assertEquals( "Object", ClassUtil.getSimpleBaseClassName(true) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetNameByPrimitiveClass() : void
		{
			assertEquals( "Object", ClassUtil.getSimpleBaseClassName(Boolean) );
		}
		
//------------------------------------------------------------------------------
		
		public function testGetNameFailureOnNull() : void
		{
			try
			{
				ClassUtil.getSimpleBaseClassName(null);
			} 
			catch ( e:ArgumentError )
			{
				return;
			}
			catch ( e:Error )
			{
				throw	new AssertionFailedError(
							AssertResources.getString("Errors.AssertFailedError.UnexpectedErrorType", ClassUtil.getQualifiedClassName(e))
						);
			}
			
			throw	new AssertionFailedError(
							AssertResources.getString("Errors.AssertFailedError.ErrorTypeExpected", ClassUtil.getQualifiedClassName(ArgumentError))
						);
		}
		
//------------------------------------------------------------------------------
	
	}
	
}
